﻿#pragma once
#include "AsGraphicsObject.h"

AS_MEMBER_CLASS_DECLARATION(AsGraphicsChart);

class AS_GRAPHICS_API AsGraphicsChart : public AsGraphicsObject, public AsBinder<AsGraphicsChart> {
public:
	explicit AsGraphicsChart(QObject* parent = nullptr);
	explicit AsGraphicsChart(AsGraphics* graphics, QObject* parent = nullptr);
	~AsGraphicsChart();
	enum AxisOption {
		AxisYLeft,
		AxisYRight,
		AxisXTop,
		AxisXBottom
	};

private:
	AS_MEMBER_CLASS(AsGraphicsChart)* mp;

public:
	void create(AsGraphics* graphics, QObject* parent = nullptr);
	void destroy();

public:
	void setCoordinateSystemSize(const QSizeF& size);
	void setCoordinateSystemGeometry(const QRectF& rect);
	void setAxis(AxisOption axisType, const QString& title, double valueBegin, double valueEnd, int partCount, int keepDecimal = 1, bool showGridLine = false);
	void setDefaultAxis(double xValueBegin, double xValueEnd, double yValueBegin, double yValueEnd, int xPartCount, int yPartCount, int xKeepDecimal = 1, int yKeepDecimal = 1, bool showGridLine = false);
	void setDefaultAxis(const QString& xTitle, const QString& yYitle, double xValueBegin, double xValueEnd, double yValueBegin, double yValueEnd, int xPartCount, int yPartCount, int xKeepDecimal = 1, int yKeepDecimal = 1, bool showGridLine = false);
	void destroyAxis(AxisOption axisType);

public:
	void addScatters(const QString& identifier, const QVector<QPointF>& points, int radius = 0, const QColor& color = Qt::red, AsGraphicsChart::AxisOption referenceAxisX = AxisXBottom, AsGraphicsChart::AxisOption referenceAxisY = AxisYLeft);
	void addScatters(const QString& identifier, const QVector<QPointF>& points, int radius = 0, const QVector<QColor>& colors = QVector<QColor>(), const QColor& generalColor = Qt::red, AsGraphicsChart::AxisOption referenceAxisX = AxisXBottom, AsGraphicsChart::AxisOption referenceAxisY = AxisYLeft);
	void addPolyline(const QString& identifier, const QVector<QPointF>& points, const QPen& penLine = QPen(Qt::blue), AsGraphicsChart::AxisOption referenceAxisX = AxisXBottom, AsGraphicsChart::AxisOption referenceAxisY = AxisYLeft);
	void addPolylineWithVertex(const QString& identifier, const QVector<QPointF>& points, int radius = 1, const QColor& colorVertex = Qt::red, const QPen& penLine = QPen(Qt::blue), AsGraphicsChart::AxisOption referenceAxisX = AxisXBottom, AsGraphicsChart::AxisOption referenceAxisY = AxisYLeft);
	void destroyElement(const QString& identifier);
	void destroyAllElement();

public:
	void setEnable_fillFullWidget(bool isEnable = true, const QMarginsF& margins = QMarginsF(80, 80, 80, 80));

};

namespace AsGraphicsNamespace {
	typedef AsGraphicsChart Chart;
};